export function validate(data: any, rule?: {
  min?: number,
  max?: number,
  type?: 'number' | 'string' | 'boolean' | 'function' | 'object',
}) {
  if (!rule) {
    return true;
  }
  if (
    (typeof rule.min !== 'undefined' && data < rule.min) ||
    (typeof rule.max !== 'undefined' && data > rule.max) ||
    (typeof rule.type !== 'undefined' && typeof data !== rule.type)
  ) {
    return false;
  }
  return true;
}